package com.abss.vote.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class RedisKeyUtils {

//活动
    //保存活动总浏览数
    public static final String ACTIVITY_VISIST = "ACTIVITY_VISIST";
    //保存活动报名人数
    public static final String REG_USER = "REG_USER";
    //保存活动投票人数
    public static final String VOTES_USER = "VOTES_USER";
    //保存活动总点赞数
    public static final String VOTES_NUMBER = "VOTES_NUMBER";
    //保存活动每天限制点赞数
    public static final String VOTES_LIMIT_PERDAY = "VOTES_LIMIT_PERDAY";
    //保存活动作品点赞数
    public static final String VOTES_LIMIT_TOSINGLE_PERDAY = "VOTES_LIMIT_TOSINGLE_PERDAY";
    //保存作品点赞数量
    public static final String WORK_VOTES = "WORK_VOTES";
    //保存作品浏览数量
    public static final String WORK_VISIST = "WORK_VISIST";
    //保存点赞信息
    public static final String VOTES = "VOTES";
    //保存点赞用户信息
    public static final String USER_VOTES_INFO = "USER_VOTES_INFO";

    /**
     * 设置VOTES表的key值
     * @param activityId  活动id
     * @param workId   作品id
     * @param userId   用户id（点赞人）
     * @return
     */
    public static String setVOTES(String activityId,String workId,String userId) {
        StringBuilder builder = new StringBuilder();
        builder.append(activityId);
        builder.append("::");
        builder.append(workId);
        builder.append("::");
        builder.append(userId);
        return builder.toString();
    }

    /**
     * 设置VOTES表的key值
     * @param activityId  活动id
     * @param userId   用户id（点赞人）
     * @return
     */
    public static String setVOTESkey(String activityId,String userId) {
        StringBuilder builder = new StringBuilder();
        builder.append(activityId);
        builder.append("::");
        builder.append(userId);
        return builder.toString();
    }

    /**
     * 设置VOTES表的value值
     * @param userVoteInfo
     * @param workId
     * @return
     */
    public static String setVOTESVALUE(String userVoteInfo,Integer workId) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        StringBuilder builder = new StringBuilder();
        if("1".equals(userVoteInfo)){//第一次添加
            builder.append(workId);
            builder.append("::");
            builder.append(sdf.format(new Date()));
        }else {
            builder.append(userVoteInfo);
            builder.append(":::");
            builder.append(workId);
            builder.append("::");
            builder.append(sdf.format(new Date()));
        }
        return builder.toString();
    }

    /**
     * 设置USER_VOTES_INFO表的key值
     * @param activityId  活动id
     * @param userId   用户id（点赞人）
     * @return
     */
    public static String setUSER_VOTES_INFO(String activityId,String userId) {
        StringBuilder builder = new StringBuilder();
        builder.append(activityId);
        builder.append("::");
        builder.append(userId);
        return builder.toString();
    }
}
